<?php

use common\server\BasicDataServer;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\bootstrap\Modal;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model common\models\HouseModel */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="house-model-form">

    <?php $form = ActiveForm::begin(); ?>

    <div class="row">
        <div class="col-lg-6">

			<?= $form->field($model, 'atype')->dropDownList(BasicDataServer::instance()->getAdvTypeOptions(), ['encodeSpaces' => 1]) ?>
			<?= $form->field($house, 'house_name')->textInput(['readonly'=>'readonly','id'=>'housename']);?>
			<?= $form->field($model, 'houseid')->textInput(['type'=>'hidden','id'=>'houseidname'])->label(false);?>
			
			

			<?php 
    	
			echo Html::a('选择楼盘', '#', [
			    'id' => 'create',
			    'data-toggle' => 'modal',
			    'data-target' => '#create-modal',//关联下面Model的id属性
			    'class' => 'btn btn-success',
			]);
			
			Modal::begin([
			    'id' => 'create-modal',
			    'header' => '<h4 class="modal-title">选择店铺</h4>',
			    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">关闭</a>',
			]); 
			
			$requestUrl = Url::toRoute('/house/index-select');
			$js = <<<JS
			    $(document).on('click', '#create', function () {
			        $.get('{$requestUrl}', {},
			            function (data) {
			                $('.modal-body').html(data);
			            }  
			        );
			    });
JS;
		
				$this->registerJs($js);
				
				Modal::end(); 
			?>
			
			<br>
			<br>
				
			<?= $form->field($model, 'advicon')->fileInput() ?>
			
            <?php
            if(!empty($model->advicon)){
                echo "<img src='{$model->advicon}' style='max-height: 200px; max-width: 200px'/><br/><br/>";
            }
			
            ?>

        </div>
    </div>
	
	<br>
	<br>
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '添加广告' : '修 改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>
    

    	
    

</div>
